<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="pub/top.jsp"%>
<!-- 全局变量 函数定义区 -->
<%!%>
<!-- 实例变量 函数定义区 -->
<%
	//网页title
    String JSPTITLE = "忘记密码,邮箱找回";
    String url_login=basePath+"ex/login.jsp";
%>
<%@ include file="pub/head.jsp"%>
<script type="text/javascript">


	const URL_VERIFYCODE="<%=basePath%>ex/getVerifyCode";
	const URL_SMSREG="<%=basePath%>l/getRegSms";
	const URL_SMSFORGOT="<%=basePath%>l/getForgotSms";	

	const URL_TELEXIST="<%=basePath%>telIsExist";
	const URL_IDEXIST="<%=basePath%>idIsExist";
	const URL_RESETPASS="<%=basePath%>l/resetPass";


  function sendsms(){
    reloadSmsCode(URL_SMSLOGIN,'#a_sms1','#phone1','#msg1')
  }
  //获取短信验证码
  function reloadSmsCode(url,vbtn, vinput, vlabel) {
    //如果相等 退出，防止重复提交			
    $(vlabel).html('');
    var phone = $(vinput).val();
    if (phone == null || phone == "") {
      $(vlabel).html("请输入手机号码");
      return;
    }
   /*  if (!Chk.isCHMobile(phone)) {
      $(vlabel).html("请输入正确的手机号码");
      return;
    } */
    var param = {}
    param.phone = phone;
    Chk.submitByWait( url, param, vbtn, function(e) {
      if (e.code == "1") {
        $(vlabel).html("验证码已发");
      } else
        if (e.code == "0") {
          $(vlabel).html(e.msg);
        } else {
          $(vlabel).html(e);
        }
    }, function(e) {
      alert(MSG_400);
    });
  }

  //忘记密码1
  function reset1(vbtn) {
    var vlabel = "#msg1";
    var param = {};
    param.phone = $("#phone1").val();
    param.pass = $("#pass1").val();
    var pass2 = $("#pass12").val();
    param.mcode = $("#code1").val();
    if (param.phone == null || param.phone == "") {
      $(vlabel).html("手机号码必填");
      return;
    }
    if (param.mcode == null || param.mcode == "") {
      $(vlabel).html("请确认短信验证码已经发送到你的手机");
      return;
    }
    if (pass == null || pass.length<3) {
      $(vlabel).html("密码不能为空,且长度需大于2位");
      return;
    }
    if (pass != param.pass) {
      $(vlabel).html("密码错误");
      return;
    }
    Chk.submit(URL_RESETPASS, param, vbtn, function(data) {
      console.log(data);
      $(vlabel).html(data.head.msg);
    }, function(xhr, type, errorThrown) {
      //异常处理；
      alert(MSG_400);
    });
  }
  $(document).ready(function() {
   
    $('#btn_forgot').on('click', function(e) {
      reset1('#btn_forgot');
      e.preventDefault();
    });
   
  });
</script>
<!-- 样式添加区 -->
<style>

</style>
<br>
<br>
<br>
<br>
<body class="login-layout">
 <div class="main-container">
  <div class="main-content">
   <div class="row">
    <div class="col-sm-10 col-sm-offset-1">
     <div class="login-container">
      <div class="center">
       <h1>
        <i class="ace-icon fa fa-leaf green"></i>
        <span class="white" id="id-text2" style="font-size: 14pt"><%=SYSTEM %></span>
       </h1>
      </div>
      <div class="space-6"></div>
      <div class="position-relative">     
       <div id="forgot-box" class="forgot-box  visible widget-box no-border">
        <div class="widget-body">
         <div class="widget-main">
          <h4 class="header red lighter bigger">
           <i class="ace-icon fa fa-key"></i>
<%=JSPTITLE %>
          </h4>
          <div class="space-6"></div>
          <p>通过手机短信验证码,重置密码</p>
          <form>
           <fieldset>
            <label class="block clearfix">
             <span class="block input-icon input-icon-right">
              <input type="text" id="phone1" class="form-control" placeholder="手机号码" />
              <i class="ace-icon fa fa-phone"></i>
             </span>
            </label>
            <label class="block clearfix">
             <span class="block input-icon input-icon-right">
              <input type="password" class="form-control " id="code1" placeholder="验证码" />
              <a id="a_sms1" href="javascript:sendsms();">
               <label>发送短信</label>
              </a>
              <br>
             </span>
            </label>
            <label class="block clearfix">
             <span class="block input-icon input-icon-right">
              <input type="text" id="pass1" class="form-control" placeholder="输入新的密码" />
              <i class="ace-icon fa fa-lock"></i>
             </span>
            </label>
            <label class="block clearfix">
             <span class="block input-icon input-icon-right">
              <input type="text" id="pass12" class="form-control" placeholder="确认密码" />
              <i class="ace-icon fa fa-retweet"></i>
             </span>
            </label>
            <div class="clearfix">
             <button type="button" id="btn_forgot"
              class="width-35 pull-right btn btn-sm btn-danger">
              <i class="ace-icon fa fa-lightbulb-o"></i>
              <span class="bigger-110">提交</span>
             </button>
            </div>
           </fieldset>
          </form>
         </div>
         <!-- /.widget-main -->
         <div class="toolbar center">
          <a href="<%=url_login%>" class="back-to-login-link">
           <i class="ace-icon fa fa-arrow-right"></i>
           登录
          </a>
         </div>
        </div>
        <!-- /.widget-body -->
       </div>
       <!-- /.forgot-box -->
     
      </div>
    
     </div>
    </div>
    <!-- /.col -->
   </div>
   <!-- /.row -->
  </div>
  <!-- /.main-content -->
 </div>
 <!-- /.main-container -->
 <!-- inline scripts related to this page -->
 <script type="text/javascript">
    jQuery(function($) {
      $(document).on('click', '.toolbar a[data-target]', function(e) {
        e.preventDefault();
        var target = $(this).data('target');
        $('.widget-box.visible').removeClass('visible');//hide others
        $(target).addClass('visible');//show target
      });
    });
   
  </script>
</body>
</html>
<%@ include file="pub/bottom.jsp"%>
<!-- 扩展脚本 注入区 -->
